﻿using System.Web;
using System.Web.Mvc;
using ML.Entity;
using ML.IBusiness;
using System.IO;
using ML.Utils;

namespace ML.Web.Controllers
{
    /// <summary>
    /// 平台分类控制器
    /// </summary>
    public class PlatFormCategoryController : BaseController
    {
        private readonly IPlatFormCategoryBusiness pfcBusiness;
        public PlatFormCategoryController(IPlatFormCategoryBusiness _pfcBusiness)
        {
            pfcBusiness = _pfcBusiness;
        }

        /// <summary>
        /// 平台分类页面
        /// </summary>
        /// <returns></returns>
        public ActionResult Index()
        {
            ViewBag.InitInfo = "平台分类";
            return View();
        }

        /// <summary>
        /// 根据查询条件查询用户信息
        /// </summary>
        /// <param name="pfcSearch">用户查询条件</param>
        /// <returns></returns>
        [HttpGet]
        [AjaxOnly]
        public ActionResult List(PlatFormCategorySearch pfcSearch)
        {
            var data = pfcBusiness.List(pfcSearch);
            return JsonDateTime(data.data);
        }

        /// <summary>
        /// 查询平台分类未删除未禁用的所有数据
        /// </summary>
        /// <returns></returns>
        [HttpGet]
        [AjaxOnly]
        public ActionResult GetDropDownListList()
        {
            var data = pfcBusiness.GetDropDownListList();
            return Json(data, JsonRequestBehavior.AllowGet);
        }

        /// <summary>
        /// 添加平台分类
        /// </summary>
        /// <param name="entity">平台分类实体</param>
        /// <returns></returns>
        [HttpPost]
        [AjaxOnly]
        public ActionResult Add(PlatformCategoryEntity entity)
        {
            var data = pfcBusiness.Add(entity);
            return Json(data);
        }

        /// <summary>
        /// 修改平台分类
        /// </summary>
        /// <param name="entity">平台分类实体</param>
        /// <returns></returns>
        [HttpPost]
        [AjaxOnly]
        public ActionResult Edit(PlatformCategoryEntity entity)
        {
            var data = pfcBusiness.Update(entity);
            return Json(data);
        }

        /// <summary>
        /// 删除用户
        /// </summary>
        /// <param name="id">主键</param>
        /// <returns></returns>
        [HttpPost]
        [AjaxOnly]
        public ActionResult Delete(string id)
        {
            var data = pfcBusiness.Delete(id);
            return Json(data);
        }
    }
}